package starter.actions.orangehrmlive;

/**
 * @ClassName LoginPageSteps
 * @Date 2024/10/29 11:37 23
 * @Author Jack Chen
 * @Description serenity-cucumber-page-objects-starter-master
 * @Version 1.0
 */
import net.serenitybdd.annotations.Step;
import org.junit.Assert;
import starter.pageobjects.orangehrmlive.LoginPage;
import java.util.Objects;

public class LoginPageSteps {
    LoginPage loginPage;

    @Step("User opens the orangehrm login page")
    public void openOrangehrmLoginPage() {
        loginPage.open();
    }

    @Step
    public void loginPageShows() {
        String title = loginPage.getLoginTitle();
        assert Objects.equals(title, "Login");
    }

    @Step("input username")
    public void inputUsername(String username) {
        loginPage.usernameInput(username);
    }

    @Step("input user password")
    public void inputUserPassword(String password) {
        loginPage.passwordInput(password);
    }

    @Step("click on login commit button")
    public void clickOnLogonCommitButton() {
        loginPage.clickOnLogon();
    }

    @Step("verity the user name required message show correct")
    public void verifyUsernameWarnMsg(String msg) {
        String actMsg = loginPage.getNameReqWarnMsg();
        Assert.assertEquals(actMsg, msg);
    }

    @Step("verity the user password required message show correct")
    public void verifyPasswordWarnMsg(String msg) {
        String actMsg = loginPage.getPassReqWarnMsg();
        Assert.assertEquals(actMsg, msg);
    }

    @Step("verity login page show error message")
    public void verifyLoginPageShowErrorMsg(String msg) {
        String actMsg = loginPage.getInvalidCredentialsErrMsg();
        Assert.assertEquals(actMsg, msg);
    }
}
